﻿<Window
   x:Class="ValidationTest.MainWindow"
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:src="clr-namespace:ValidationTest"
   Title="MainWindow"
   Height="350"
   Width="525">
   <Window.Resources>
      <Style
         TargetType="{x:Type TabItem}">
         <Style.Triggers>
            <DataTrigger
               Binding="{Binding Content.(src:View.HasChildErrors), RelativeSource={RelativeSource Self}}"
               Value="True">
               <Setter
                  Property="Background"
                  Value="Red" />
            </DataTrigger>
         </Style.Triggers>
      </Style>

   </Window.Resources>
   <Grid>
      <Grid.RowDefinitions>
         <RowDefinition
            Height="*" />
         <RowDefinition
            Height="Auto" />
      </Grid.RowDefinitions>
      <TabControl>
         <TabItem
            x:Name="_tabItem1"
            Header="Item 1">
            <ContentControl
               src:View.ChildErrorMonitoringIsEnabled="True">
               <DataGrid
                  ItemsSource="{Binding Employees}">
                  <DataGrid.Columns>
                     <DataGridTextColumn
                        Header="Name"
                        Binding="{Binding Name, ValidatesOnDataErrors=True, NotifyOnValidationError=True}" />
                     <DataGridTextColumn
                        Header="Salary"
                        Binding="{Binding Salary, ValidatesOnDataErrors=True, NotifyOnValidationError=True}" />
                  </DataGrid.Columns>
               </DataGrid>
            </ContentControl>
         </TabItem>
         <TabItem
            x:Name="_tabItem2"
            Header="Item 2">
            <ContentControl
               src:View.ChildErrorMonitoringIsEnabled="True">
               <TextBox
                  Text="{Binding Turnover, ValidatesOnDataErrors=True, NotifyOnValidationError=True}"
                  VerticalAlignment="Top" />
            </ContentControl>
         </TabItem>
      </TabControl>
      <Button
         Grid.Row="1"
         Content="Debug"
         Click="Button_Click" />
   </Grid>
</Window>
